package com.xdxc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xdxc.model.entity.BankQuestion;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface BankQuestionMapper extends BaseMapper<BankQuestion> {

    @Insert({
            "<script>",
            "INSERT INTO bank_question (bank_id, question_id, custom_score, custom_difficulty, add_by)",
            "VALUES",
            "<foreach collection='list' item='item' separator=','>",
            "(#{item.bankId}, #{item.questionId}, #{item.customScore}, #{item.customDifficulty}, #{item.addBy})",
            "</foreach>",
            "ON DUPLICATE KEY UPDATE bank_id = bank_id",
            "</script>"
    })
   boolean batchInsertIgnoreDuplicate(@Param("list") List<BankQuestion> list);
}